# 导入shutil模块和os模块

import os
import shutil

path_input = r'\\172.18.5.225\data2\wangshuan\TAI40-II\train\xiaoyangpin'
path_out   = r'\\172.18.5.226\data4\wangshuan\TAI40-II\train\xiaoyangpin'


list_copy = ['label_dhq_ok.txt']
for root_dirs, sub_dirs, files in os.walk(path_input):
    for file in files:  # 复制文件
        if file in list_copy:
            file_name_1 = os.path.join(root_dirs, file)
            file_name_new_1 = file_name_1.replace(path_input, path_out)
            print(file_name_1)
            print(file_name_new_1)
            try:
                shutil.copy(file_name_1, file_name_new_1)
            except:
                pass